<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        .light {
            width: 50px;
            height: 50px;
            border: 1px solid #ddd;
            border-radius: 50%;
        }

        .btn {
            padding: 5px;
            outline: none;
            border: none;
            margin-top: 15px;
        }

        .turn-on {
            background-color: #fff;
        }

        .turn-off {
            background-color: #000;
        }

        .turn-on .light {
            background-color: lightyellow;
            box-shadow: 0px 0px 5px 10px lightyellow;
        }

        #main {
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: start;
            align-items: center;
        }

        .line {
            width: 2px;
            background-color: #000;
            height: calc(50vh - 50px);
        }
    </style>
</head>
<body>
    <main id="main" class="turn-on">
        <div class="line"></div>
        <div class="light"></div>
        <button class="btn">关</button>
    </main>
</body>
<script>
    let btn = document.querySelector(".btn");
    let main = document.querySelector("#main");
    let classList = main.classList;

    btn.addEventListener("click",function() {
        classList.toggle("turn-on");
        classList.toggle("turn-off");
        // if (btn.innerHTML == '开') {
        //     btn.innerHTML = '关'
        // } else {
        //     btn.innerHTML = '开'
        // }
        btn.innerText = btn.innerText == '开' ? '关' : '开';
    })


</script>
</html>